package com.xnyzc.lhy.order.common.userenum;

import com.xnyzc.lhy.common.exception.PangException;
import com.xnyzc.lhy.common.penum.EErrorCode;
import com.xnyzc.lhy.common.util.CheckUtil;

/**
 * 用户状态
 * @author cuixiaojian
 */
public enum EBlock {

    /**
     * 正常用户
     */
    NO_ERR(0, "正常用户"),
    /**
     * 黑名单用户
     */
    BLACK(1, "黑名单用户"),
    /**
     * 用户已注销
     */
    OUT(2, "用户已注销");

    private Integer key;
    private String value;

    EBlock(Integer key, String value) {
        this.key = key;
        this.value = value;
    }

    public static String value(Integer key) {
        if (CheckUtil.objIsNotEmpty(key)) {
            for (EBlock examine : EBlock.values()) {
                if (key.equals(examine.getKey())) {
                    return examine.getValue();
                }
            }
        }
        throw PangException.create(EErrorCode.noData);
    }

    public Integer getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

}
